package com.zyh.homeworkzhuantike;

import java.util.Scanner;

public class Test20 {
    public static void main(String[] args) {
        /*
        10.	读入一个小于10的整数n，输出它的阶乘。提示：n的阶乘 = n * (n-1) * (n-2) ...* 1
        6!=6*5*4*3*2*1
        6!=6*(6-1)*(6-2)*(6-3)*(6-4)*(6-5)*(6-6)
         */
//        Scanner接收数据
        System.out.println("请输入一个整数：");
        int num = new Scanner(System.in).nextInt();
        if (num > 10) {
            System.out.println("数据大于10");
            return;
        }
//        定义结果变量
        int result = 1;
        if (num == 0) {
            System.out.println("result = 0");
            return;
        }
        for (int i = 1; i <= num; i++) {
            result *= i;
        }
        System.out.println(num+"的阶乘是：" + result);
    }
}
